using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PACKETPARSERMAX20.CORE;

namespace PACKETPARSERMAX20.CORE.DEFINITIONS
{
    public class SMSG_NPC_TEXT_UPDATE_DEF : DefinitionBase
    {

        public override bool Process()
        {
            ResetPosition();

            var template = GetNPCText();
            GlobalCache.AddNPCTextSum(template, ClientBuild);
            return Validate();
        }

        public npc_text GetNPCText()
        {
            ResetPosition();

            npc_text template = new npc_text();

            template.id = ReadUInt32();

            template.prob0 = ReadSingle();
            template.text0_0 = ReadString();
            template.text0_1 = ReadString();
            template.lang0 = (byte)ReadUInt32();
            template.em0_0 = (ushort)ReadUInt32();
            template.em0_1 = (ushort)ReadUInt32();
            template.em0_2 = (ushort)ReadUInt32();
            template.em0_3 = (ushort)ReadUInt32();
            template.em0_4 = (ushort)ReadUInt32();
            template.em0_5 = (ushort)ReadUInt32();

            template.prob1 = ReadSingle();
            template.text1_0 = ReadString();
            template.text1_1 = ReadString();
            template.lang1 = (byte)ReadUInt32();
            template.em1_0 = (ushort)ReadUInt32();
            template.em1_1 = (ushort)ReadUInt32();
            template.em1_2 = (ushort)ReadUInt32();
            template.em1_3 = (ushort)ReadUInt32();
            template.em1_4 = (ushort)ReadUInt32();
            template.em1_5 = (ushort)ReadUInt32();

            template.prob2 = ReadSingle();
            template.text2_0 = ReadString();
            template.text2_1 = ReadString();
            template.lang2 = (byte)ReadUInt32();
            template.em2_0 = (ushort)ReadUInt32();
            template.em2_1 = (ushort)ReadUInt32();
            template.em2_2 = (ushort)ReadUInt32();
            template.em2_3 = (ushort)ReadUInt32();
            template.em2_4 = (ushort)ReadUInt32();
            template.em2_5 = (ushort)ReadUInt32();

            template.prob3 = ReadSingle();
            template.text3_0 = ReadString();
            template.text3_1 = ReadString();
            template.lang3 = (byte)ReadUInt32();
            template.em3_0 = (ushort)ReadUInt32();
            template.em3_1 = (ushort)ReadUInt32();
            template.em3_2 = (ushort)ReadUInt32();
            template.em3_3 = (ushort)ReadUInt32();
            template.em3_4 = (ushort)ReadUInt32();
            template.em3_5 = (ushort)ReadUInt32();

            template.prob4 = ReadSingle();
            template.text4_0 = ReadString();
            template.text4_1 = ReadString();
            template.lang4 = (byte)ReadUInt32();
            template.em4_0 = (ushort)ReadUInt32();
            template.em4_1 = (ushort)ReadUInt32();
            template.em4_2 = (ushort)ReadUInt32();
            template.em4_3 = (ushort)ReadUInt32();
            template.em4_4 = (ushort)ReadUInt32();
            template.em4_5 = (ushort)ReadUInt32();

            template.prob5 = ReadSingle();
            template.text5_0 = ReadString();
            template.text5_1 = ReadString();
            template.lang5 = (byte)ReadUInt32();
            template.em5_0 = (ushort)ReadUInt32();
            template.em5_1 = (ushort)ReadUInt32();
            template.em5_2 = (ushort)ReadUInt32();
            template.em5_3 = (ushort)ReadUInt32();
            template.em5_4 = (ushort)ReadUInt32();
            template.em5_5 = (ushort)ReadUInt32();

            template.prob6 = ReadSingle();
            template.text6_0 = ReadString();
            template.text6_1 = ReadString();
            template.lang6 = (byte)ReadUInt32();
            template.em6_0 = (ushort)ReadUInt32();
            template.em6_1 = (ushort)ReadUInt32();
            template.em6_2 = (ushort)ReadUInt32();
            template.em6_3 = (ushort)ReadUInt32();
            template.em6_4 = (ushort)ReadUInt32();
            template.em6_5 = (ushort)ReadUInt32();

            template.prob7 = ReadSingle();
            template.text7_0 = ReadString();
            template.text7_1 = ReadString();
            template.lang7 = (byte)ReadUInt32();
            template.em7_0 = (ushort)ReadUInt32();
            template.em7_1 = (ushort)ReadUInt32();
            template.em7_2 = (ushort)ReadUInt32();
            template.em7_3 = (ushort)ReadUInt32();
            template.em7_4 = (ushort)ReadUInt32();
            template.em7_5 = (ushort)ReadUInt32();
            return template;
        }
    }
}

